package com.home.common.enums;

public enum StatusEnum {
    DISABLE("无效", new Byte((byte)0)),
    ENABLE("生效", new Byte((byte)1));

    private String msg;
    private Byte code;

    private StatusEnum(String msg, Byte code) {
        this.msg = msg;
        this.code = code;
    }
    public static String getMsgByCode(Byte code){
        StatusEnum [] enums = StatusEnum.values();
        for (StatusEnum statusEnum:enums){
            if(statusEnum.getCode().equals(code)){
                return statusEnum.getMsg();
            }
        }
        return "";
    }

    public static boolean isValidCode(Byte code) {
        for (StatusEnum statusEnum : StatusEnum.values()) {
            if (code.equals(statusEnum.getCode())) {
                return true;
            }
        }
        return false;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Byte getCode() {
        return code;
    }

    public void setCode(Byte code) {
        this.code = code;
    }
}
